package com.yyh.synctool.client.tool;

import com.yyh.synctool.client.job.TaskId;
import org.quartz.JobKey;

/**
 * @author xuan
 * @date 2021/12/6
 */
public class TaskKey
{
    private static Key TEST = new Key("task", "test");
    private static Key STOCK = new Key("task", "stock");
    private static Key PRICE = new Key("task", "price");

    public static JobKey getJobKey(String taskId) {
        switch (taskId) {
            case TaskId.TEST: return getTestJobKey();
            case TaskId.STOCK: return getStockJobKey();
            case TaskId.PRICE: return getPriceJobKey();

            default: return null;
        }
    }

    public static JobKey getTestJobKey() {
        return new JobKey(TEST.getGroup(), TEST.getName());
    }

    public static JobKey getStockJobKey() {
        return new JobKey(STOCK.getGroup(), STOCK.getName());
    }

    public static JobKey getPriceJobKey() {
        return new JobKey(PRICE.getGroup(), PRICE.getName());
    }

    private static class Key {
        private String group;
        private String name;

        public Key(String group, String name) {
            this.group = group;
            this.name = name;
        }

        public String getGroup() { return group; }
        public String getName() { return name; }
    }
}
